package com.guigu.gulisearch.entity;


import com.guigu.gulicommon.constant.enumes.ware.HasStock;
import com.guigu.gulicommon.entity.pojo.AttrsPoJo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.dromara.easyes.annotation.HighLight;
import org.dromara.easyes.annotation.IndexField;
import org.dromara.easyes.annotation.IndexId;
import org.dromara.easyes.annotation.IndexName;
import org.dromara.easyes.annotation.rely.Analyzer;
import org.dromara.easyes.annotation.rely.FieldStrategy;
import org.dromara.easyes.annotation.rely.FieldType;
import org.dromara.easyes.annotation.rely.IdType;

import java.math.BigDecimal;
import java.util.List;

/**
 * es 商品信息
 *
 * @author 陈俊杰
 * @version 1.0
 * @since 2024/8/25 22:46
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@IndexName(value = "product")
public class ProductEs {
    /**
     * es主键
     */
    @IndexId(type = IdType.CUSTOMIZE)
    private Long id;
    /**
     * 单款商品id
     */
    @IndexField(fieldType = FieldType.LONG)
    private Long skuId;
    /**
     * 商品spuId
     */
    @IndexField(fieldType = FieldType.KEYWORD)
    private Long spuId;
    /**
     * 单款商品名称
     */
    @IndexField(fieldType = FieldType.TEXT, analyzer = Analyzer.IK_SMART)
    @HighLight(preTag = "<b style= color:red>", postTag = "</b>")
    private String skuTitle;
    /**
     * 单款商品价格
     */
    @IndexField(fieldType = FieldType.KEYWORD)
    private BigDecimal skuPrice;
    /**
     * 单款商品图片
     */
    @IndexField(fieldType = FieldType.TEXT, analyzer = Analyzer.IK_SMART)
    private String skuImg;
    /**
     * 销量
     */
    @IndexField(fieldType = FieldType.LONG)
    private Long saleCount;
    /**
     * 是否有库存
     *
     * @see HasStock#getName()
     */
    @IndexField(fieldType = FieldType.TEXT)
    private HasStock hasStock;
    /**
     * 热度评分
     */
    @IndexField(fieldType = FieldType.LONG)
    private Long hotScore;
    /**
     * 商品所属品牌id
     */
    @IndexField(fieldType = FieldType.LONG, strategy = FieldStrategy.NOT_EMPTY)
    private Long brandId;
    /**
     * 商品所属分类id
     */
    @IndexField(fieldType = FieldType.LONG, strategy = FieldStrategy.NOT_EMPTY)
    private Long catalogId;
    /**
     * 品牌名称
     */
    @IndexField(fieldType = FieldType.TEXT, strategy = FieldStrategy.NOT_EMPTY)
    private String brandName;
    /**
     * 品牌图片地址
     */
    @IndexField(fieldType = FieldType.TEXT, strategy = FieldStrategy.NOT_EMPTY)
    private String brandImg;
    /**
     * 分类名称
     */
    @IndexField(fieldType = FieldType.TEXT, strategy = FieldStrategy.NOT_EMPTY)
    private String catalogName;
    /**
     * 规格参数信息
     */
    @IndexField(fieldType = FieldType.NESTED, nestedClass = AttrsPoJo.class)
    private List<AttrsPoJo> attrs;

    /**
     * 获取规格字段列名
     *
     * @return 规格字段列名
     */
    public static String getAttrsColumnName() {
        return "attrs";
    }
}
